package org.csu.jpetstore.service;

import org.csu.jpetstore.domain.Account;
import org.csu.jpetstore.domain.Cart;
import org.csu.jpetstore.domain.Order;
import org.csu.jpetstore.persistence.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private Order order;

    public Order createOrder(Account account, Cart cart){
        order.initOrder(account, cart);
        return order;
    }

    public Order getOrder(String orderId){
        return orderMapper.getOrder(orderId);
    }

    public List<Order> getOrderByUsername(String username){
        return orderMapper.getOrdersByUsername(username);
    }

    public void insertOrder(Order order){orderMapper.insertOrder(order);}
}
